Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom HTML at the Top of "<body>" #1695

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ab-tools
Copy link

@ab-tools ab-tools commented Jan 1, 2024

Added setCustomTopBodyElement allowing to define custom HTML to be added at the top of the "" tag.

This is very useful to add a custom HTML header, e. g. also a logo at the top of the page.

I know this would in general be possible with WIFI_MANAGER_OVERRIDE_STRINGS and copying the whole wm_strings_en.h file, however, if the only goal is to add a single line of HTML code at the top of the page this seems like a bad idea:
Whenever something would get added in that file, these changes would need to be copied over manually to the custom file again.

Having the option to just "inject" and additional HTML code at the top of the body tag (similar as it is already possible to inject something at the bottom of the "head" tag) seems a much better option.

@anishsane
Copy link

anishsane commented Aug 21, 2024

Since you have already done this, may I suggest a change to add a footer as well? (setCustomFooterElement)

I am currently using a hack to add a footer using javascript like this:

wm.setCustomHeadElement("<script>setTimeout(function(){document.querySelector('.wrap').appendChild(document.createTextNode('Build time: " __DATE__ "/" __TIME__ "'));}, 100);</script>");

(I could not use the timestamp from the info page, since it is a timestamp of when the wifi-manager library files were compiled. For repeated builds, old library .o files are reused.)

But having a separate setCustomFooterElement function would be a much simpler approach.

@dmadison
Copy link

This is great! I hope you don't mind, I reworked the name as "body header" and added a corresponding "footer" function, PR #1769.

@tablatronix tablatronix added the enhancement Feature Request label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants